package com.lijian.community.utils;

import com.github.pagehelper.PageInfo;


import java.util.List;

public class PagedResultUtil<T> {
    /**
     * 封装分页
     *
     * @return
     */
    public  PagedResult setPagedResult(List list) {

        PageInfo<T> pageInfo = new PageInfo<>(list);

        PagedResult pagedResult = new PagedResult();
        pagedResult.setPrePage(pageInfo.getPrePage());
        pagedResult.setNextPage(pageInfo.getNextPage());
        pagedResult.setRows(list);
        pagedResult.setRecords(pageInfo.getTotal());
        pagedResult.setTotal(pageInfo.getPages());

        return pagedResult;
    }
}
